<!--
  @author mujunlin
  @since 2019/10/17 19:06
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:replace="common/common :: jscss2"/>
</head>
<body>
<div class="layui-fluid">

    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-tab layui-tab-brief"  lay-filter="changeFirstTab">
                <ul class="layui-tab-title">
                    <li class="layui-this" lay-id="newOrderId">新单</li>
                    <li lay-id="repairOrderId">返修单</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div th:replace="orderconfig/distribute/company/_new_order::new_order"/>
                    </div>
                    <div class="layui-tab-item ">
                        <div th:replace="orderconfig/distribute/company/_repair_order::repair_order"/>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
</html>
<style>
    .layui-laydate-content > .layui-laydate-list {
        padding-bottom: 0px;
        overflow: hidden;
    }

    .layui-laydate-content > .layui-laydate-list > li {
        width: 50%
    }

    .merge-box .scrollbox .merge-list {
        padding-bottom: 5px;
    }
</style>
<script type="text/javascript" th:inline="javascript">
    var json = {
        obj: [[${obj}]],
        robOrderObj:[[${robOrderObj}]],
        engineerList:[[${engineerList}]],
        provinceList: [[${provinceList}]],
        provinceDisable: [[${provinceDisable}]],
        cityList: [[${cityList}]],
        cityDisable: [[${cityDisable}]]
    };

    // 定义下拉框实例
    var city, provice,robOrderCity,robOrderProvince;

    layui.config({
        base: "/static/lay/",
        version: 202009041518
    }).extend({
        index: "lib/index",
        orderconfig_distribute_edit: "orderconfig/distribute/zmn.orderconfig.distribute.edit"
    }).use(['index', 'orderconfig_distribute_edit'], function () {

        // 渲染
        if (json.obj.distributeWay == 10) {

            city = xmselectinit('city', json.cityList, null, json.provinceDisable);
            province = xmselectinit('province', json.provinceList, city, json.cityDisable);
            robOrderCity = xmselectinit('robOrderCity', json.cityList, null, json.provinceDisable);
            robOrderProvince = xmselectinit('robOrderProvince', json.provinceList, robOrderCity, json.cityDisable);
        }

    });

    function xmselectinit(element, data, searchItem, disabled) {

        var tips = searchItem != null ? "请选择省" : "请选择城市";
        var item = xmSelect.render({
            el: '#' + element,
            name: element + "Id",
            layVerify: 'required',
            layVerType: 'msg',
            radio: true,
            clickClose: true,
            filterable: true,
            disabled: disabled,
            tips: tips,
            model: {
                icon: 'hidden',
                label: {
                    type: 'text'
                }
            },
            toolbar: {show: true},
            on: function (data) {
                if (searchItem != null) {
                    var params = {};
                    params.provinceId = data.change[0].value;
                    params.bizType = json.obj.bizType;
                    params.distributePlatId = json.obj.distributePlatId;
                    params.plat = layui.$("#plat option:selected").val();
                    layui.$.ajax({
                        type: "POST", url: '/orderconfig/distribute/ajax/searchCity',
                        dataType: "json", data: params,
                        success: function (json) {
                            if (json.status == 200) {
                                searchItem.update({
                                    data: json.data,
                                    autoRow: true
                                })
                            } else {
                                console.log(json.message);
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                        }
                    });
                }
            },
            data: data
        });
        return item;
    }

</script>

